Skip to content

feat: add validFor function to return the validity interval #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

2color
Copy link
Member

@2color 2color commented Jun 19, 2025

What

  • feat: add validFor function to which returns the number of milliseconds until the record expires.
  • feat: export protobuf functions

Open questions

  • Other name ideas for this function: expiresIn or getExpiry

@2color 2color requested review from achingbrain and SgtPooki June 19, 2025 11:45
@2color 2color changed the title feat: add validity validator feat: add validFor function to return the validity interval Jun 19, 2025
@2color 2color requested a review from Copilot June 20, 2025 08:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a helper to compute how long an IPNS record remains valid and exposes protobuf entry points.

  • Introduces validFor to calculate milliseconds until expiration or throw on invalid records
  • Expands tests in validator.spec.ts to cover validFor behavior
  • Updates package.json exports to include the protobuf directory

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test/validator.spec.ts Added tests for validFor and updated imports
src/validator.ts Implemented validFor and adjusted imports
package.json Exposed ./pb protobuf exports
Comments suppressed due to low confidence (2)

test/validator.spec.ts:117

  • This test is intended to cover the branch where record.validity is null, but it currently nulls validityType instead. Change it to record.validity = null as any so the validFor function's null-validity check is exercised.
      record.validityType = null as any

src/validator.ts:114

  • [nitpick] Update the parameter description to reflect that this function calculates expiration, e.g., @param record - The IPNS record to evaluate for expiration.
 * @param record - The IPNS record to validate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant